package com.bookmanger.controller;

import com.bookmanger.common.result.Result;
import com.bookmanger.entity.Manager;
import com.bookmanger.entity.dto.AddMangerDTO;
import com.bookmanger.entity.dto.ManagerDTO;
import com.bookmanger.entity.request.BookMangerRestoreRequest;
import com.bookmanger.entity.select.ManagerListDto;
import com.bookmanger.entity.vo.ListForm;
import com.bookmanger.entity.vo.managerListVo;
import com.bookmanger.service.ManagerService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @author huangfuhao
 * @folder 管理员
 * @Date 2024/10/28
 */
@RestController
@RequestMapping("/manager")
public class MangerController {
    @Resource
    private ManagerService managerService;

    /**
     * 管理员登陆
     *
     * @param manager
     * @return
     */
    @PostMapping("/login")
    public Result<ManagerDTO> login(@RequestBody Manager manager) {
        return managerService.login(manager);
    }

    /**
     * 查询管理员列表
     *
     * @param userListDto
     * @return
     */
    @PostMapping("/managerList")
    public Result<ListForm<managerListVo>> getManagerList(@RequestBody ManagerListDto userListDto) {
        return managerService.getManagerList(userListDto);
    }

    /**
     * 停用管理员账号
     *
     * @param id
     * @return
     */
    @GetMapping("/managerDisable")
    public Result managerDisable(@RequestParam Long id) {
        return managerService.managerDisable(id);
    }

    /**
     * 启用管理员账号
     *
     * @param id
     * @return
     */
    @GetMapping("/managerEnable")
    public Result managerEnable(@RequestParam Long id) {
        return managerService.managerEnable(id);
    }

    /**
     * 添加管理员用户
     *
     * @param addMangerDTO
     * @return
     */
    @PostMapping("/addManager")
    public Result addManager(@RequestBody AddMangerDTO addMangerDTO) {
        return managerService.addManager(addMangerDTO);
    }

    /**
     * 审核还书
     */
    @PostMapping("managerRestore")
    public Result managerRestore (@RequestBody BookMangerRestoreRequest bookMangerRestoreRequest){
        return managerService.managerRestore(bookMangerRestoreRequest);
    }
}